﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace ValidatorDemo
{
    public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();
        }

        private void _ValidateAll_Click(object sender, RoutedEventArgs e)
        {
            List<Silverlight.Validators.ValidatorBase> validators = Group1.ValidateAll();

            if (validators.Count > 0)
            {
                //could use the content of the list to show an invalid message summary somehow
                MessageBox.Show(validators.Count.ToString() + " invalid validators");
            }
            else
            {
                MessageBox.Show("All valid!");
            }
        }

		private bool CustomValidator_CustomValidate(object ElementToValidate)
		{
			TextBox box = ElementToValidate as TextBox;
			return box.Text == "Custom";
		}
    }
}
